<?php
use yii\helpers\Html;
use yii\helpers\Url;
use app\models\U;

/* @var $this yii\web\View */
$this->title = '首页';

//租赁中的商品
$goods1 = \app\models\MGoods::find()->where(['status' => 1, 'pub_type' => 1])->orderBy(['update_time' => SORT_DESC])->limit(4)->all();
$goods1_cnt = \app\models\MGoods::find()->where(['status' => 1, 'pub_type' => 1])->count();

//出售中的新品
$goods2 = \app\models\MGoods::find()->where(['status' => 1, 'pub_type' => 2, 'goods_neworold' => 1])->orderBy(['update_time' => SORT_DESC])->all();
$goods2_cnt = \app\models\MGoods::find()->where(['status' => 1, 'pub_type' => 2, 'goods_neworold' => 1])->count();

//出售中的二手
$goods3 = \app\models\MGoods::find()->where(['status' => 1, 'pub_type' => 2,  'goods_neworold' => 2])->orderBy(['update_time' => SORT_DESC])->all();
$goods3_cnt = \app\models\MGoods::find()->where(['status' => 1, 'pub_type' => 2,  'goods_neworold' => 2])->count();

//行业新闻    公司动态 展会信息
$news1 = \app\models\News::find()->where(['cat' => 1])->orderBy(['update_time' => SORT_DESC])->all();
$news2 = \app\models\News::find()->where(['cat' => 2])->orderBy(['update_time' => SORT_DESC])->all();
$news3 = \app\models\News::find()->where(['cat' => 3])->orderBy(['update_time' => SORT_DESC])->all();

//解决方案  产品学习 技术文章
/*
4 => '解决方案',
5 => '产品学习',
6 => '技术文章',
7 => '招才纳士',
8 => '仪表维修',
9 => '仪表校准',
*/

$news4 = \app\models\News::find()->where(['cat' => 4])->orderBy(['update_time' => SORT_DESC])->all();
$news5 = \app\models\News::find()->where(['cat' => 5])->orderBy(['update_time' => SORT_DESC])->all();
$news6 = \app\models\News::find()->where(['cat' => 6])->orderBy(['update_time' => SORT_DESC])->all();

$news7 = \app\models\News::find()->where(['cat' => 7])->orderBy(['update_time' => SORT_DESC])->all();
$news8 = \app\models\News::find()->where(['cat' => 8])->orderBy(['update_time' => SORT_DESC])->all();
$news9 = \app\models\News::find()->where(['cat' => 9])->orderBy(['update_time' => SORT_DESC])->all();


//轮播图 新版
$imgs = \app\models\Carousel::find()->where(['status' => 1])->orderBy(['order_num' => SORT_DESC])->all();

?>

<style type="text/css">

  .wrap {
      min-height: 100%;
      height: auto;
      margin: 0 auto -60px;
      padding: 0 0 0;
  }

  .iconspan {
    border: 1px solid #A9C9E2;
    background-color: #E8F5FE;
    color: #b5b5b5;
    height: 64px;
    width: 64px;
    font-size: 36px;
    text-align: center;
  line-height: 64px;;
  }

  .label {
    display: inline;
    padding: .3em .3em .3em .3em;
    font-size: 12px;
    /* font-weight: bold; */
    line-height: 2;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 3px;
  }
</style>


<div class="site-index">

<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
  <!-- Indicators -->
  <ol class="carousel-indicators">
    <?php 
      $i = 0;
      foreach ($imgs as $img ) {

      if($i == 0)
      {
        $i ++;
    ?>
    <li data-target="#carousel-example-generic" data-slide-to="<?= $i ?>" class="active"></li>
     <?php
       } 
       else 
       {
    ?>
      <li data-target="#carousel-example-generic" data-slide-to="<?= $i ?>"></li>
    <?php 
        }
      }
    ?>

  </ol>

  <!-- Wrapper for slides -->
  <div class="carousel-inner" role="listbox">
    <?php 
      $i = 0;
      foreach ($imgs as $img ) {

      if($i == 0)
      {
        $i ++;
    ?>
    <div class="item active">
      <img src='<?= $img->image ?>' width="100%">
      <div class="carousel-caption">
          <h3><?= $img->title ?></h3>
          <p><?= $img->text ?></p>
      </div>
    </div>
    <?php
       } 
       else 
       {
    ?>
      <div class="item">
        <img src='<?= $img->image ?>' width="100%">
        <div class="carousel-caption">
            <h3><?= $img->title ?></h3>
            <p><?= $img->text ?></p>
        </div>
      </div>
    <?php 
        }
      }
    ?>

  </div>

  <!-- Controls -->
  <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>

    <div class="body-content">
      <br>

    <!-- 按4大分类 给出入口-->
    <div class="panel panel-info">
      <div class="panel-heading">
        <h3>
          仪表展示
        </h3>
      </div>

      <div class="panel-body">
        <?php
          $n = 0;

          $userid = Yii::$app->user->isGuest?-1:Yii::$app->user->identity->id;

          $cats = \app\models\Category::find()->where(['parent_id' => 0])->all();
          foreach ($cats as $cat) 
          {
            $goods = \app\models\MGoods::find()->where(['goods_kind' => $cat->id])->orderBy(['update_time' => SORT_DESC])->all();
        ?>
        <?php if($n%4 == 0) {?>
              <div class="row">
        <?php } ?>
          <div class="col-xs-12 col-md-3">
            <div class="thumbnail">

              <!--
              <//?= Html::a('<img src='. $goods[0]->list_img_url. '>', ['site/client-goods-view', 'id' => $goods[0]->goods_id]) ?>
              -->
              <img src='<?= $goods[0]->list_img_url ?>'>

              <div class="caption">

                <!--
                <h4><//?=  mb_substr($cat->name, 0, 20, 'utf-8')."..."  ?></h4>
                -->
                <!--
                <h3><//?=  $cat->name; ?></h3>
                -->
                <!--
                <p><//?=  mb_substr($g->descript, 0, 32, 'utf-8')."..."  ?></p>
                -->
                <br>
                <p>
                 <?= Html::a( $cat->name, ['site/client-goods-list', 'pub_userid' => $userid, 'goods_kind' => $cat->id], ['class' => 'btn btn-primary btn-block']) ?>
                </p>
      
              </div>
            </div>
          </div>
        <?php if(($n+1)%4 == 0) {?>
            </div>
        <?php } ?>
        <?php
            $n = $n + 1;
          }
        ?> 

      </div>
    </div>

      <div class="row">
        <div class="col-lg-12 col-xs-12">
          <div class="panel panel-info">
            <div class="panel-heading">
              <h3>
                租赁
                <span class="badge"><?= $goods1_cnt ?></span>
                &nbsp;&nbsp;
                <small>
                  <?= Html::a('更多 >>',  ['site/client-pubgoods-list', 'pub_type' => 1, 'goods_neworold' => 0]) ?>
                </small>
              </h3>
            </div>

            <div class="panel-body">

              <?php
              $n = 0;
              foreach ($goods1 as $g)
              {
                ?>
                <?php if($n%4 == 0)  {?>
                <div class="row">
              <?php } ?>
                <div class="col-xs-12 col-md-3">
                  <div class="thumbnail">
                    <?= Html::a('<img  src='. $g->list_img_url . ' width=100%>',  ['site/client-pubgoods-view', 'id' => $g->goods_id]) ?>

                    <div class="caption">
                      <br>
                      <p>
                        <b><?= $g->title ?></b>
                      </p>

                      <p>
                        <?= $g->parameter ?>
                      </p>
                    </div>
                  </div>
                </div>
                <?php if(($n+1)%4 == 0) {?>
                </div>
              <?php } ?>
                <?php
                $n = $n + 1;
              }
              ?>

            </div>
          </div>
        </div><!-- ./col -->

        </div>

      <div class="row">

          <div class="col-lg-6 col-xs-12">
            <div class="panel panel-info">
              <div class="panel-heading">
                <h3>
                  出售-新品
                  <span class="badge"><?= $goods2_cnt ?></span>
                  &nbsp;&nbsp;
                  <small>
                    <?= Html::a('更多 >>',  ['site/client-pubgoods-list', 'pub_type' => 2, 'goods_neworold' => 1]) ?>
                  </small>
                </h3>
              </div>

              <div class="panel-body">
                <ul class="media-list">
                  <?php
                  $n = 0;
                  foreach ($goods2 as $g)
                  {
                    $n ++;
                    ?>
                    <li class="media">
                      <div class="media-left">
                        <?= Html::a('<img class="media-object"  src='. $g->list_img_url . ' style="width: 64px; height: 64px;">',  ['site/client-pubgoods-view', 'id' => $g->goods_id]) ?>
                      </div>
                      <div class="media-body">
                        <h5 class="media-heading">
                          <span class="label label-success"><?= $g->title; ?></span>
                        </h5>
                        <?= $g->parameter; ?>
                      </div>
                    </li>
                    <?php
                    if($n ==3) break;
                  }
                  ?>
                </ul>

              </div>
            </div>
          </div><!-- ./col -->

          <div class="col-lg-6 col-xs-12">
            <div class="panel panel-info">
              <div class="panel-heading">
                <h3>
                  出售-二手
                  <span class="badge"><?= $goods3_cnt ?></span>
                  &nbsp;&nbsp;
                  <small>
                    <?= Html::a('更多 >>',  ['site/client-pubgoods-list', 'pub_type' => 2, 'goods_neworold' => 2]) ?>
                  </small>
                </h3>
              </div>

              <div class="panel-body">
                <ul class="media-list">
                  <?php
                  $n = 0;
                  foreach ($goods3 as $g)
                  {
                    $n ++;
                    ?>
                    <li class="media">
                      <div class="media-left">
                        <?= Html::a('<img class="media-object"  src='. $g->list_img_url . ' style="width: 64px; height: 64px;">',  ['site/client-pubgoods-view', 'id' => $g->goods_id]) ?>
                      </div>
                      <div class="media-body">
                        <h5 class="media-heading">
                          <span class="label label-warning"><?= $g->title; ?></span>
                        </h5>
                        <?= $g->parameter; ?>
                      </div>
                    </li>
                    <?php
                    if($n ==3) break;
                  }
                  ?>
                </ul>

              </div>
            </div>
          </div><!-- ./col -->
        </div>


      <div class="row">

        <div class="col-lg-6 col-xs-12">
          <div class="panel panel-success">
            <div class="panel-heading">
              <h3>
                仪表维修
                &nbsp;&nbsp;
                <small>
                  <?= Html::a('更多 >>',  ['site/client-news-list', 'cat' =>8]) ?>
                </small>
              </h3>
            </div>

            <div class="panel-body">
              <ul class="media-list">
                <?php
                $n = 0;
                foreach ($news8 as $ns)
                {
                  $n ++;
                  ?>
                  <li class="media">
                    <div class="media-left">
                      <?= Html::a(' <span class="iconspan glyphicon glyphicon-wrench"></span>', ['site/client-news-view', 'id' => $ns->news_id]) ?>
                    </div>
                    <div class="media-body">
                      <h5 class="media-heading">
                        <span class="label label-success"><?= $ns->title; ?></span>
                      </h5>
                      发布时间：<?= $ns->create_time; ?>
                    </div>
                  </li>
                  <?php
                  if($n ==5) break;
                }
                ?>
              </ul>

            </div>
          </div>
        </div>

        <div class="col-lg-6 col-xs-12">
          <div class="panel panel-success">
            <div class="panel-heading">
              <h3>
                仪表校准
                &nbsp;&nbsp;
                <small>
                  <?= Html::a('更多 >>',  ['site/client-news-list', 'cat' =>9]) ?>
                </small>
              </h3>
            </div>

            <div class="panel-body">
              <ul class="media-list">
                <?php
                $n = 0;
                foreach ($news9 as $ns)
                {
                  $n ++;
                  ?>
                  <li class="media">
                    <div class="media-left">
                      <?= Html::a(' <span class="iconspan glyphicon glyphicon-scale"></span>', ['site/client-news-view', 'id' => $ns->news_id]) ?>
                    </div>
                    <div class="media-body">
                      <h5 class="media-heading">
                        <span class="label label-success"><?= $ns->title; ?></span>
                      </h5>
                      发布时间：<?= $ns->create_time; ?>
                    </div>
                  </li>
                  <?php
                  if($n ==5) break;
                }
                ?>
              </ul>

            </div>
          </div>
        </div>

      </div>


      <div class="row">
        <div class="col-lg-4 col-xs-12">
          <div class="panel panel-info">
                <div class="panel-heading">
                  <h3>
                    行业新闻
                    &nbsp;&nbsp;
                    <small>
                      <?= Html::a('更多 >>',  ['site/client-news-list', 'cat' =>1]) ?>
                    </small>
                  </h3>
                </div>

                <div class="panel-body">
                  <ul class="media-list">
                    <?php
                    $n = 0;
                    foreach ($news1 as $ns)
                    {
                      $n ++;
                      ?>
                      <li class="media">
                        <div class="media-left">
                          <?= Html::a(' <span class="iconspan glyphicon glyphicon-blackboard"></span>',  ['site/client-news-view', 'id' => $ns->news_id]) ?>
                        </div>
                        <div class="media-body">
                          <h5 class="media-heading">
                            <span class="label label-info"><?= $ns->title; ?></span>
                          </h5>
                         发布时间：<?= $ns->create_time; ?>
                        </div>
                      </li>
                      <?php
                      if($n ==5) break;
                    }
                    ?>
                  </ul>

                </div>
              </div>
          </div>

        <div class="col-lg-4 col-xs-12">
              <div class="panel panel-info">
                <div class="panel-heading">
                  <h3>
                    公司动态
                    &nbsp;&nbsp;
                    <small>
                      <?= Html::a('更多 >>',  ['site/client-news-list', 'cat' =>2]) ?>
                    </small>
                  </h3>
                </div>

                <div class="panel-body">
                  <ul class="media-list">
                    <?php
                    $n = 0;
                    foreach ($news2 as $ns)
                    {
                      $n ++;
                      ?>
                      <li class="media">
                        <div class="media-left">
                          <?= Html::a(' <span class="iconspan glyphicon glyphicon-signal"></span>', ['site/client-news-view', 'id' => $ns->news_id]) ?>
                        </div>
                        <div class="media-body">
                          <h5 class="media-heading">
                            <span class="label label-info"><?= $ns->title; ?></span>
                          </h5>
                         发布时间：<?= $ns->create_time; ?>
                        </div>
                      </li>
                      <?php
                      if($n ==5) break;
                    }
                    ?>
                  </ul>

                </div>
              </div>
        </div>

        <div class="col-lg-4 col-xs-12">
          <div class="panel panel-info">
            <div class="panel-heading">
              <h3>
                展会信息
                &nbsp;&nbsp;
                <small>
                  <?= Html::a('更多 >>',  ['site/client-news-list', 'cat' =>3]) ?>
                </small>
              </h3>
            </div>

            <div class="panel-body">
              <ul class="media-list">
                <?php
                $n = 0;
                foreach ($news3 as $ns)
                {
                  $n ++;
                  ?>
                  <li class="media">
                    <div class="media-left">
                      <?= Html::a(' <span class="iconspan glyphicon glyphicon-bullhorn"></span>', ['site/client-news-view', 'id' => $ns->news_id]) ?>
                    </div>
                    <div class="media-body">
                      <h5 class="media-heading">
                        <span class="label label-info"><?= $ns->title; ?></span>
                      </h5>
                     发布时间：<?= $ns->create_time; ?>
                    </div>
                  </li>
                  <?php
                  if($n ==5) break;
                }
                ?>
              </ul>

            </div>
          </div>
        </div>

      </div>

      <div class="row">
        <div class="col-lg-4 col-xs-12">
          <div class="panel panel-info">
            <div class="panel-heading">
              <h3>
                解决方案
                &nbsp;&nbsp;
                <small>
                  <?= Html::a('更多 >>',  ['site/client-news-list', 'cat' =>4]) ?>
                </small>
              </h3>
            </div>

            <div class="panel-body">
              <ul class="media-list">
                <?php
                $n = 0;
                foreach ($news4 as $ns)
                {
                  $n ++;
                  ?>
                  <li class="media">
                    <div class="media-left">
                      <?= Html::a(' <span class="iconspan  glyphicon glyphicon-th-large"></span>', ['site/client-news-view', 'id' => $ns->news_id]) ?>
                    </div>
                    <div class="media-body">
                      <h5 class="media-heading">
                        <span class="label label-info"><?= $ns->title; ?></span>
                      </h5>
                      发布时间：<?= $ns->create_time; ?>
                    </div>
                  </li>
                  <?php
                  if($n ==5) break;
                }
                ?>
              </ul>

            </div>
          </div>
        </div>

        <div class="col-lg-4 col-xs-12">
          <div class="panel panel-info">
            <div class="panel-heading">
              <h3>
                产品学习
                &nbsp;&nbsp;
                <small>
                  <?= Html::a('更多 >>',  ['site/client-news-list', 'cat' =>5]) ?>
                </small>
              </h3>
            </div>

            <div class="panel-body">
              <ul class="media-list">
                <?php
                $n = 0;
                foreach ($news5 as $ns)
                {
                  $n ++;
                  ?>
                  <li class="media">
                    <div class="media-left">
                      <?= Html::a(' <span class="iconspan glyphicon glyphicon-send"></span>', ['site/client-news-view', 'id' => $ns->news_id]) ?>
                    </div>
                    <div class="media-body">
                      <h5 class="media-heading">
                        <span class="label label-info"><?= $ns->title; ?></span>
                      </h5>
                      发布时间：<?= $ns->create_time; ?>
                    </div>
                  </li>
                  <?php
                  if($n ==5) break;
                }
                ?>
              </ul>

            </div>
          </div>
        </div>

        <div class="col-lg-4 col-xs-12">
          <div class="panel panel-info">
            <div class="panel-heading">
              <h3>
                技术文章
                &nbsp;&nbsp;
                <small>
                  <?= Html::a('更多 >>',  ['site/client-news-list', 'cat' =>6]) ?>
                </small>
              </h3>
            </div>

            <div class="panel-body">
              <ul class="media-list">
                <?php
                $n = 0;
                foreach ($news6 as $ns)
                {
                  $n ++;
                  ?>
                  <li class="media">
                    <div class="media-left">
                      <?= Html::a(' <span class="iconspan glyphicon glyphicon-book"></span>', ['site/client-news-view', 'id' => $ns->news_id]) ?>
                    </div>
                    <div class="media-body">
                      <h5 class="media-heading">
                        <span class="label label-info"><?= $ns->title; ?></span>
                      </h5>
                      发布时间：<?= $ns->create_time; ?>
                    </div>
                  </li>
                  <?php
                  if($n ==5) break;
                }
                ?>
              </ul>

            </div>
          </div>
        </div>
        </div>


    </div>

    <!-- -->
<br><br><br>
  </div>
